package com.mmall.admin.shiro;

import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.SessionContext;
import org.apache.shiro.session.mgt.SessionFactory;
import org.springframework.stereotype.Component;

/**
 * @author gg
 * @version MmallSessionFactory.java, v 0.1 2019-05-16 15:59 gg
 */
@Component
public class MmallSessionFactory implements SessionFactory {


    /**
     * Creates a new {@code Session} instance based on the specified contextual initialization data.
     *
     * @param initData the initialization data to be used during {@link Session} creation.
     * @return a new {@code Session} instance.
     * @since 1.0
     */
    @Override
    public Session createSession(SessionContext initData) {
        if (initData != null) {
            String host = initData.getHost();
            if (host != null) {
                return new MmallSimpleSession(host);
            }
        }
        return new MmallSimpleSession();
    }
}